#include "../include/threadPool.h"

int main(int argc, char *argv[]){                                  
    threadPool_t threadPool;
    threadPoolInit(&threadPool,5);
    int sockfd = tcpInit("192.168.201.130","45678");
    int epfd = epoll_create(1);
    epollAdd(epfd,sockfd);
    makeWorker(&threadPool); 
    struct epoll_event readyset[1024];
    while(1){
        int readyNum = epoll_wait(epfd,readyset,1024,-1);
        for(int i = 0; i < readyNum; i++){
            if(readyset[i].data.fd == sockfd){
                int netfd = accept(sockfd,NULL,NULL);
                pthread_mutex_lock(&threadPool.mutex);
                enQueue(&threadPool.taskQueue,netfd);
                pthread_cond_broadcast(&threadPool.cond);
                pthread_mutex_unlock(&threadPool.mutex);
            }
        }
    }
    return 0;
}

